Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
Why is this "Hello, World!" JavaScript code fragment recognized as an acceptable program instruction?

Recently a coworker showed this fragment of JavaScript code:

greet = "‮".toString.bind("hello world!")

If you paste this inside the Developer Console and execute it will print a "Hello, World!" message:

>> console.log(greet())
hello, world!

Another interesting thing I found is that if you paste the same greet code inside Node.js REPL it will automatically transpile it to a "readable" format.

How does this work? Why is this behaviour possible in a browser and why does Node.js automatically format it?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

The actual code is:

greet = "...".toString.bind("hello world!")

Where the ... in the string literal are the bytes E2 80 AE, which is the right-to-left override Unicode character, which causes everything after it to be displayed in reverse. It's used for writing right-to-left languages like Arabic or Hebrew.

hex editors are your friend

over 4 years ago · Santiago Trujillo Relatório

0

You have hidden characters which reverse the text. Here you can see the raw characters: https://www.soscisurvey.de/tools/view-chars.php

enter image description here

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda